<template>
  <div>
    <!--积分设置-->
    <div class="common-form">积分设置</div>
    <el-form-item label="是否开启积分赠送：">
      <el-radio-group v-model="form.model.is_points_gift">
        <el-radio :label="1">开启</el-radio>
        <el-radio :label="0">关闭</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="是否允许使用积分抵扣：">
      <el-radio-group v-model="form.model.is_points_discount">
        <el-radio :label="1">允许</el-radio>
        <el-radio :label="0">不允许</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item
      v-if="form.model.is_points_discount == 1"
      label="最大抵扣积分数量："
      :rules="[{ required: true, message: ' ' }]"
      prop="model.max_points_discount"
    >
      <el-input
        type="number"
        v-model="form.model.max_points_discount"
        class="max-w460"
      ></el-input>
      <div class="gray9">最大抵扣积分数量，-1为使用通用设置</div>
    </el-form-item>

    <!--分销设置-->
    <!-- <div class="common-form" v-if="form.basicSetting.is_open == 1">
      分销设置
    </div>
    <el-form-item label="是否开启分销：" v-if="form.basicSetting.is_open == 1">
      <el-radio-group v-model="form.model.is_agent">
        <el-radio :label="0">关闭</el-radio>
        <el-radio :label="1">开启</el-radio>
      </el-radio-group>
    </el-form-item>
    <template v-if="form.model.is_agent === 1">
      <el-form-item label="分销规则：" v-if="form.basicSetting.is_open == 1">
        <el-radio-group v-model="form.model.is_ind_agent">
          <el-radio :label="0">平台规则</el-radio>
          <el-radio :label="1">单独规则</el-radio>
        </el-radio-group>
        <div class="gray9">
          平台规则：层级({{ form.basicSetting.level }}级)
          <span v-if="form.basicSetting.level >= 1" style="padding-left: 10px"
            >1级佣金({{ form.agentSetting.first_money }}%)</span
          >
          <span v-if="form.basicSetting.level >= 2" style="padding-left: 10px"
            >2级佣金({{ form.agentSetting.second_money }}%)</span
          >
          <span v-if="form.basicSetting.level >= 3" style="padding-left: 10px"
            >3级佣金({{ form.agentSetting.third_money }}%)</span
          >
        </div>
      </el-form-item>
      <template
        v-if="form.model.is_ind_agent === 1 && form.basicSetting.is_open == 1"
      >
        <el-form-item label="分销佣金类型：">
          <el-radio-group
            v-model="form.model.agent_money_type"
            @change="changeMoneyType"
          >
            <el-radio :label="10">百分比</el-radio>
            <el-radio :label="20">固定金额</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="单独分销设置：">
          <el-input
            type="number"
            min="0"
            v-model="form.model.first_money"
            class="max-w460"
          >
            <template #prepend> 一级佣金： </template>
            <template #append>
              {{ unit }}
            </template>
          </el-input>
        </el-form-item>
        <el-form-item v-if="form.basicSetting.level >= 2">
          <el-input
            type="number"
            min="0"
            v-model="form.model.second_money"
            class="max-w460"
          >
            <template #prepend> 二级佣金： </template>
            <template #append>
              {{ unit }}
            </template>
          </el-input>
        </el-form-item>
        <el-form-item v-if="form.basicSetting.level >= 3">
          <el-input
            type="number"
            min="0"
            v-model="form.model.third_money"
            class="max-w460"
          >
            <template #prepend> 三级佣金： </template>
            <template #append>
              {{ unit }}
            </template>
          </el-input>
        </el-form-item>
      </template>
    </template> -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      unit: "%",
      grade_unit: "%",
    };
  },
  created() {
    if (this.form.model.alone_grade_type == "20") {
      this.grade_unit = "元";
    }
    if (this.form.model.agent_money_type == "20") {
      this.unit = "元";
    }
  },
  inject: ["form"],
  methods: {
    /*换算单位*/
    changeMoneyType: function (val) {
      if (val == "10") {
        this.unit = "%";
      } else {
        this.unit = "元";
      }
    },
    /*换算单位*/
    changeGradeType: function (val) {
      if (val == "10") {
        this.grade_unit = "%";
      } else {
        this.grade_unit = "元";
      }
    },
  },
};
</script>

<style></style>
